package cyberdict.scr;

import java.util.StringTokenizer;

public class InfoWord {
	private String word;
	private String size;
	private String offset;
	public InfoWord()
	{
		word="";
		size="";
		offset="";
	}
	public InfoWord(String word, String offset, String size)
	{
		this.word=word;
		this.offset=offset;
		this.size=size;
	}
	public InfoWord(String lineWord)
	{
		StringTokenizer arr= new StringTokenizer(lineWord,"'\t'");
		if (arr.countTokens()>=3)
		{
			this.word=arr.nextToken();
			this.offset=arr.nextToken();
			this.size=arr.nextToken();
		}
		else
		{
			word="";
			size="";
			offset="";
		}
		
		
	}
	public String getWord()
	{
		return word;
	}
	public String getOffset()
	{
		return offset;
	}
	public String getSize()
	{
		return size;
	}
	public int getOffset_Dec()
	{
		String base64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
		int decValue=0;
		int len= offset.length();
		int pos;
		if (len==0)
			return -1;
		for (int i=0; i<len; i++)
		{
			pos=base64.indexOf(offset.charAt(i));
			if (pos==-1)
				return -1;
			decValue+=(int)Math.pow(64,len-i-1)*pos;
		}
		return decValue;
	}
	public int getSize_Dec()
	{
		String base64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
		int decValue=0;
		int len= size.length();
		int pos;
		if (len==0)
			return -1;
		for (int i=0; i<len; i++)
		{
			pos=base64.indexOf(size.charAt(i));
			if (pos==-1)
				return -1;
			decValue+=(int)Math.pow(64,len-i-1)*pos;
		}
		return decValue;
	}
}
